# -*- coding: utf-8 -*-

# graphic-pppoe-client - Easy graphic networking manager
#
# Author: GoTLiuM InSPiRiT <gotlium@gmail.com>
#
# Copyright 2010, GoTLiuM InSPiRiT <gotlium@gmail.com>.
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program.  If not, see <http://www.gnu.org/licenses/>.

from libraries.fw import enableForwarding, disableForwarding, addUser, delUser
from models.__init__ import getConnectionById

class Users(object):
	
	def setUsers(self):
		connection = getConnectionById(connId)
		if str(connection['shared']) == 'true':
			enableForwarding(connection['if_name'])
		else:
			for row in self.selectUsers(connId):
				addUser(row['user_ip'], row['user_mac'])

	def delUsers(self):
		connection = getConnectionById(connId)
		if str(connection['shared']) == 'true':
			disableForwarding(connection['if_name'])
		else:
			for row in self.selectUsers(connId):
				delUser(row['user_ip'], row['user_mac'])
